add_library(ETHERNET_FILES STATIC)

target_sources(ETHERNET_FILES PUBLIC
    ${WIZNET_DIR}/Ethernet/socket.c
    ${WIZNET_DIR}/Ethernet/wizchip_conf.c
)

target_include_directories(ETHERNET_FILES INTERFACE
    ${WIZNET_DIR}/Ethernet
    ${WIZNET_DIR}/Ethernet/W5500
)

target_link_libraries(ETHERNET_FILES PUBLIC
    W5500_FILES
)

add_library(W5500_FILES STATIC)

target_sources(W5500_FILES PUBLIC
        ${WIZNET_DIR}/Ethernet/W5500/w5500.c
)

target_include_directories(W5500_FILES INTERFACE
        ${WIZNET_DIR}/Ethernet
        ${WIZNET_DIR}/Ethernet/W5500
)

target_link_libraries(W5500_FILES PRIVATE
        ETHERNET_FILES
)

add_library(DHCP_FILES STATIC)
target_sources(DHCP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/DHCP/dhcp.c
)
target_include_directories(DHCP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/DHCP
)
target_link_libraries(DHCP_FILES PRIVATE
        ETHERNET_FILES
)

add_library(DNS_FILES STATIC)
target_sources(DNS_FILES PUBLIC
        ${WIZNET_DIR}/Internet/DNS/dns.c
)
target_include_directories(DNS_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/DNS
)
target_link_libraries(DNS_FILES PRIVATE
        ETHERNET_FILES
)



add_library(FTPCLIENT_FILES STATIC)
target_sources(FTPCLIENT_FILES PUBLIC
        ${WIZNET_DIR}/Internet/FTPClient/ftpc.c
)
target_include_directories(FTPCLIENT_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/FTPClient
)
target_link_libraries(FTPCLIENT_FILES PRIVATE
        ETHERNET_FILES
)


add_library(FTPSERVER_FILES STATIC)
target_sources(FTPSERVER_FILES PUBLIC
        ${WIZNET_DIR}/Internet/FTPServer/ftpd.c
)
target_include_directories(FTPSERVER_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/FTPServer
)
target_link_libraries(FTPSERVER_FILES PRIVATE
        ETHERNET_FILES
)



add_library(HTTPSERVER_FILES STATIC)
target_sources(HTTPSERVER_FILES PUBLIC
        ${WIZNET_DIR}/Internet/httpServer/httpParser.c
        ${WIZNET_DIR}/Internet/httpServer/httpServer.c
        ${WIZNET_DIR}/Internet/httpServer/httpUtil.c
)
target_include_directories(HTTPSERVER_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/httpServer
)
target_link_libraries(HTTPSERVER_FILES PRIVATE
        ETHERNET_FILES
)


add_library(MQTT_FILES STATIC)
target_sources(MQTT_FILES PUBLIC
        ${WIZNET_DIR}/Internet/MQTT/mqtt_interface.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTConnect.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTConnectClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTConnectServer.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTDeserializePublish.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTFormat.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTPacket.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTPublish.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSerializePublish.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSubscribe.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSubscribeClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSubscribeServer.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTUnsubscribe.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeServer.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/StackTrace.h
)
target_include_directories(MQTT_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/MQTT
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src
)
target_link_libraries(MQTT_FILES PRIVATE
        ETHERNET_FILES
)


add_library(SNMP_FILES STATIC)
target_sources(SNMP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/SNMP/snmp_custom.c
        ${WIZNET_DIR}/Internet/SNMP/snmp.c
)
target_include_directories(SNMP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/httpServer
)
target_link_libraries(SNMP_FILES PRIVATE
        ETHERNET_FILES
)


add_library(SNTP_FILES STATIC)
target_sources(SNTP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/SNTP/sntp.c
)
target_include_directories(SNTP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/SNTP
)
target_link_libraries(SNTP_FILES PRIVATE
        ETHERNET_FILES
)



add_library(TFTP_FILES STATIC)
target_sources(TFTP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/TFTP/netutil.c
        ${WIZNET_DIR}/Internet/TFTP/tftp.c
)
target_include_directories(TFTP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/TFTP
)
target_link_libraries(TFTP_FILES PRIVATE
        ETHERNET_FILES
)


add_library(TCP_UDP_FILES STATIC)
target_sources(TCP_UDP_FILES PUBLIC
        ${WIZNET_DIR}/Application/loopback/loopback.c
        ${WIZNET_DIR}/Application/multicast/multicast.c
)
target_include_directories(TCP_UDP_FILES INTERFACE
        ${WIZNET_DIR}/Application
        ${WIZNET_DIR}/Application/loopback
        ${WIZNET_DIR}/Application/multicast
)
target_link_libraries(TCP_UDP_FILES PRIVATE
        ETHERNET_FILES
)
